package org.gwu.seuss.communication.util;

import java.util.Arrays;

import jline.console.ConsoleReader;

public class PasswordPrompt {

	public static char[] askForPassword(String message){
	
		/*
		char[] pwd = System.console().readPassword(message + ": ");

		//Used to zero out passwords that are longer than 50 characters.
		if(pwd.length > 50){
			Arrays.fill(pwd, ' ');
			char[] empty = {' ',' '};
			return empty;
		}
		return pwd;
		*/
		
		try{
		
			ConsoleReader console = new ConsoleReader();
			console.setPrompt(message +": ");
			String password = console.readLine(jline.console.ConsoleReader.NULL_MASK);
			console.shutdown();
			return password.toCharArray();
		}
		catch(Exception ex){
			throw new IllegalStateException("Unable to prompt");
		}
		
	}
}
